// listDlg.cpp : implementation file
//

#include "stdafx.h"
#include "list.h"
#include "listDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CListDlg dialog

CListDlg::CListDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CListDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CListDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CListDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CListDlg)
	DDX_Control(pDX, IDC_LIST1, m_ctrListEx1);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CListDlg, CDialog)
	//{{AFX_MSG_MAP(CListDlg)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CListDlg message handlers

BOOL CListDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CListDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

HCURSOR CListDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}
void AfxBox(CStringArray &strArray)
{
	CString str = _T("");
	for (int n=0; n<strArray.GetSize(); n++)
	{
		str += strArray[n] + _T(", ");
	}
	AfxMessageBox(str);
}
void CListDlg::OnOK() 
{
	// TODO: Add extra validation here

	m_ctrListEx1.InitalHeadText(2, _T("s1"), _T("s2"));
	m_ctrListEx1.AddRecord(2, _T("w1"), _T("l1"));
	m_ctrListEx1.AddRecord(2, _T("w2"), _T("l2"));
	m_ctrListEx1.AddRecord(2, _T("w3"), _T("l3"));

	CStringArray strRow;
	int i=0;
	BOOL b;
	b = m_ctrListEx1.GetColInfo(i, strRow);
	AfxBox(strRow);
	b = m_ctrListEx1.GetColInfo(i, strRow);
	AfxBox(strRow);
	b = m_ctrListEx1.GetColInfo(i, strRow);
	AfxBox(strRow);
	b = m_ctrListEx1.GetColInfo(i, strRow);
	AfxBox(strRow);


	
//	CDialog::OnOK();
}
